<!-- 修改提还箱点 -->
<template>
  <div class="edit-return-box">
    <el-dialog
      width="800px"
      class=""
      top="6vh"
      title="修改"
      :visible="$store.state.dialog.editReturnBox"
      @close="close">
      <el-row>
        <el-col :span="24">
          <el-card shadow="hover">
            <el-form :model="myData" :rules="rules" ref="myData" label-width="100px" size="mini">
              <el-row>
                <el-col :span="8">
                  <el-form-item label="堆场代码" prop="code">
                    <el-input v-model="myData.code" auto-complete="off"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="堆场名称" prop="yardName">
                    <el-input v-model="myData.yardName" auto-complete="off"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="堆场区域" prop="yardArea">
                    <el-input v-model="myData.yardArea" auto-complete="off"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="8">
                  <el-form-item label="主要船公司" prop="majorCompany">
                    <el-input v-model="myData.majorCompany" auto-complete="off"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="工作时间" prop="jobTime">
                    <el-input v-model="myData.jobTime" auto-complete="off"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="联系电话" prop="phoneNumber">
                    <el-input v-model="myData.phoneNumber" auto-complete="off"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="8">
                  <el-form-item label="是否寄单点">
                    <el-select placeholder="请选择" v-model="myData.sendPoint">
                      <el-option label="是" value="1"></el-option>
                      <el-option label="否" value="0"></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="是否暂落点">
                    <el-select placeholder="请选择" v-model="myData.temPlacement">
                      <el-option label="是" value="1"></el-option>
                      <el-option label="否" value="0"></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="是否甩挂点">
                    <el-select placeholder="请选择" v-model="myData.leftPoint">
                      <el-option label="是" value="1"></el-option>
                      <el-option label="否" value="0"></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="8">
                  <el-form-item label="详细地址" prop="address">
                    <el-input v-model="myData.address" auto-complete="off"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="eir名称" prop="eEIR_Name">
                    <el-input v-model="myData.eEIR_Name" auto-complete="off"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-form>
          </el-card>
        </el-col>
      </el-row>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="sureReturnBox('myData')" size="mini">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { updateReturnPoint } from '../api/returnTheBox'
export default {
  data () {
    return {
      rules: {
        yardName: [
          { required: true, message: '请输入堆场名称', trigger: 'blur' }
        ],
        yardArea: [
          { required: true, message: '请输入堆场区域', trigger: 'blur' }
        ]
      }
    }
  },
  props: {
    myData: {
      type: Object
    }
  },
  methods: {
    // 关闭弹窗
    close () {
      this.$store.commit('hide_edit_return_box')
    },
    // 修改提还箱点
    async editReturnBox () {
      const res = await updateReturnPoint(this.myData)
      if (res.status === 200) {
        this.$notify({
          title: '成功',
          message: res.msg,
          type: 'success'
        })
        this.$store.commit('hide_edit_return_box')
      } else {
        this.$notify({
          title: '错误',
          message: res.msg,
          type: 'error'
        })
      }
    },
    sureReturnBox (formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.editReturnBox()
        } else {
          return false
        }
      })
    }
  }
}
</script>

<style lang="less">
</style>
